<template>
  <div class="container product-info-container" v-if="data">
    <div class="product-info-pic">
      <img :src="data.image_url" alt="">
    </div>
    <div class="product-basic-info">
      <div class="product-basic-header">
        <div class="product-title">
          <div class="product-name">
            <p>{{data.goods_name}}</p>
          </div>
        </div>
      </div>
      <div class="product-basic-body">
        <div class="product-price">
          <p>兑换积分：
            <span class="price">{{data.points_number}}积分</span>
          </p>
          <p>商品价值：
            <span class="maket">￥{{data.maket_price}}元</span>
          </p>
        </div>
      </div>
      <div class="product-basic-footer">
        <div class="product-basic-tag">销量：{{data.sale_num}}</div>
        <div class="product-basic-tag">运费：{{data.shipping_price}}</div>
        <div class="product-basic-tag">库存：{{data.stock}}</div>
      </div>
    </div>
    <div class="blank-spaces"></div>
    <div class="product-card">
      <div class="product-card-header">
        <div class="icon"></div>
        <p>宝贝详情</p>
      </div>
      <div class="product-card-body">
        <img mode="widthFix" :src="item" v-for="(item,index) in content" :key="index" alt="">
      </div>
    </div>
    <div class="blank-spaces"></div>
    <div class="add-address integtal-btn" @click="$router.push({ path: '/pages/exchangeProduct/exchangeProduct',query:{id:data.id}})">立即兑换</div>
    <i-toast id="toast" />
  </div>
</template>

<script>
  import {
    mapState,
    mapMutations
  } from "Vuex";
  // 依赖

  const {
    $Toast
  } = require('@/../static/iview/base/index');
  import Banner from "@/components/banner";
  import request from "@/api/request";

  export default {
    components: {
      Banner
    },
    data() {
      return {
        data: null,
        content: [],
        
      };
    },
    methods: {
       getContent() {
        this.content = this.data.content.match(
          /http\S+([\.jpg][\.png])+/g
        );
      },
      pointsGoodsDetail() {
        // 请求商品详情
        request
          .pointsGoodsDetail({
            id: this.$route.query.id
          })
          .then(res => {
            this.data = res.data.detail;
            this.getContent();
          });
      },
    },
    mounted() {
      this.pointsGoodsDetail();
    }
  };

</script>

<style lang="less">
  .product-info-container {
    .controls {
      .icon-warp {}

      .img {
        width: 100%;
        height: 375px;
      }
    }

    .product-info-pic {
      img {
        width: 100%;
        height: 375px;
      }
    }



    .banner-tabs {}

    .banner-swiper {
      height: 375px;

    }

    .banner {
      height: 375px;

      img {
        width: 100%;
      }

      .banner-video {
        height: 375px;
      }

      .banner-pic {
        height: 375px;
        background: #F9F9F9;
      }
    }
  }

  .product-basic-info {
    background: #fff;
    padding: 15px;

    .product-basic-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;

      .product-title {
        flex: 1;

        p {
          font-size: 14px;
          font-weight: 500;
          color: rgba(96, 96, 96, 1);
          line-height: 20px;
        }

        .product-tags {
          margin-top: 8px;
          display: flex;
          align-items: center;

          .product-tag {
            margin-right: 6px;
            font-size: 10px;
            padding: 0 4px;
            line-height: 14px;
            height: 16px;
            background: rgba(255, 255, 255, 1);
            border-radius: 8px;
            border: 1px solid #ee7559;
            color: #ee7559;
          }
        }
      }

      .shard {
        display: flex;
        align-items: center;
        background: none;
        border: 0;

        img {
          width: 19px;
          height: 19px;
          margin-right: 7px;
        }

        span {
          font-size: 12px;
          color: #a0a0a0;
          line-height: 20px;
        }
      }
    }

    .product-basic-body {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-top: 15px;

      .product-price {
        font-size: 12px;
        font-weight: 400;
        color: rgba(160, 160, 160, 1);
        line-height: 20px;
        margin-right: 15px;

        .unit {
          color: #ee7559;
        }

        .price {
          color: #ee7559;
          font-size: 18px;
          line-height: 20px;
        }
      }

      .down-taotu {
        button {
          padding: 0 10px;
          height: 22px;
          background: #ee7559;
          border-radius: 11px;
          font-size: 12px;
          font-weight: 400;
          color: rgba(255, 254, 254, 1);
          line-height: 22px;
        }
      }
    }

    .product-basic-footer {
      margin-top: 10px;
      font-size: 12px;
      font-weight: 400;
      color: rgb(68, 45, 45);
      line-height: 20px;
      display: flex;
      align-items: center;

      .product-basic-tag {
        flex: 1;
        font-size: 12px;
        color: rgba(160, 160, 160, 1);
        line-height: 20px;
      }
    }
  }

  .product-card {
    background: #fff;

    .product-card-header {
      padding: 25px 0 15px;
      display: flex;
      align-items: center;

      .icon {
        display: block;
        width: 2px;
        height: 10px;
        background: #ee7559;
        border-radius: 2px;

      }

      p {
        margin-left: 12px;
        font-size: 15px;
        line-height: 1em;
        color: rgba(96, 96, 96, 1);
      }
    }

    .product-card-body {
      padding: 0 0 20px;
      font-size: 0;

      img {
        width: 100%;
      }
    }
  }

  .product-info-table {
    tr {
      display: flex;
      align-items: center;

      th {
        width: 60px;
        font-size: 13px;
        font-weight: 400;
        color: #a0a0a0;
        line-height: 28px;
      }

      td {
        font-size: 13px;
        font-weight: 400;
        color: #404040;
        line-height: 28px;
      }
    }
  }

  .nav-tab {
    padding-top: 49px;

    .nav-tab-warp {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: 49px;
      border-top: 1px solid #f8f8f8;
      background: #fff;
      display: flex;

      .nav-tab-icons {
        width: 140px;
        display: flex;
        padding: 0 10px;

        .icon {
          height: 49px;
          flex: 1;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          font-size: 0;

          ._van-icon {
            font-size: 20px;
            height: 20px;
            margin-top: -1px;
          }

          img {
            width: 20px;
            height: 20px;
          }

          p {
            margin-top: 5px;
            font-size: 12px;
            color: rgba(160, 160, 160, 1);
            line-height: 1em;
          }
        }
      }

      .nav-tab-controller {
        flex: 1;
        display: flex;
        align-items: center;

        div {
          flex: 1;
          border: 0;
          font-size: 17px;
          font-weight: 500;
          color: rgba(255, 255, 255, 1);
          border-radius: 0;
          height: 49px;
          line-height: 49px;
          text-align: center;
        }

        .default {
          background: rgba(238, 117, 89, 0.7);
        }

        .primary {
          background: rgba(238, 117, 89, 1);
        }
      }
    }
  }

  .modal {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 100;
  }

  .modal-mask {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: #000;
    opacity: 0.8;
    z-index: 10;
  }

  .modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 11;
  }


  .specifications {
    width: 100%;
    background: #fff;
  }

  .specifications {
    padding: 15px;
  }

  .specifications-header {
    display: flex;
  }

  .specifications-pic {
    width: 80px;
    height: 80px;
    background: #F9F9F9;

    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }


  .specifications-info {
    flex: 1;
    padding: 0 15px 0;

    .specifications-title {
      font-size: 14px;
      color: rgba(96, 96, 96, 1);
      line-height: 1.5em;
    }

    .specifications-note {
      margin-top: 6px;
      display: flex;
      align-items: flex-start;

      .specifications-note-type {
        font-size: 10px;
        color: rgba(96, 96, 96, 1);
        white-space: nowrap;
        padding: 5px 0;
      }

      .specifications-note-describe {
        padding: 5px;
        font-size: 10px;
        color: rgba(160, 160, 160, 1);
        background: rgba(252, 252, 252, 1);
        border-radius: 5px;
        position: relative;
        display: flex;
        align-items: center;

        span {
          flex: 1;
        }

      }
    }

    .specifications-price {
      margin-top: 6px;
      font-size: 14px;
      color: rgba(238, 117, 89, 1);
      line-height: 1em;
    }
  }

  .specifications-cell {
    padding: 15px 0;
    display: flex;
    align-items: center;

    .specifications-cell-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: flex-start;

      .specifications-size {
        font-size: 14px;
        color: rgba(96, 96, 96, 1);
        line-height: 1em;
      }

      .specifications-price {
        font-size: 12px;
        color: rgba(160, 160, 160, 1);
        line-height: 1em;
        margin-top: 8px;
      }
    }

    .specifications-cell-count {
      margin-right: 15px;
      font-size: 12px;
      color: rgba(160, 160, 160, 1);
    }

    .specifications-cell-num {}

  }

  .product-info-tab {
    padding-left: 10px;
    padding-right: 10px;
  }

  .store-coupons-list {
    background: #fff;
    overflow-x: auto;
    white-space: nowrap;
    padding-left: 15px;
    margin-bottom: 10px;
    height: 80px;
  }

  .container {
    .integtal-btn {
      background: #EE7559;
      color: #fff;
    }
  }
</style>
